/**
 * 
 */
package me.joshua.demo4j.spring.groovy.first;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import me.joshua.demo4j.spring.groovy.first.service.ScriptService;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * @author <a href="mailto:daonan.zhan@gmail.com">Joshua Zhan</a>
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:simple.xml")
public class Demo {

	@Autowired
	private ScriptService scriptService;

	@Test
	public void run() {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					System.in));
			while (true) {
				// 循环获取输入，每次有输入即进行一次调用
				String line = reader.readLine();
				if ("exit".equals(line)) {
					break;
				}
				scriptService.run();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
